package com.fak.wid;




import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;

import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.Toast;

 
public class Preferences extends PreferenceActivity  {
	private static int time = 300000;
	
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                addPreferencesFromResource(R.xml.preferences);
                
                final CheckBoxPreference checkBoxPref = (CheckBoxPreference) findPreference("checkboxPref");
                final ListPreference listPrefLang = (ListPreference)this.findPreference("listPrefLang");
                final ListPreference listPreftime = (ListPreference)this.findPreference("listPreftime");
                checkBoxPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

					public boolean onPreferenceClick(Preference preference) {
						// TODO Auto-generated method stub
						
						
						if (checkBoxPref.isChecked()){
							listPrefLang.setEnabled(true);
							
						}else{
							listPrefLang.setEnabled(false);
							
						}
						return true;
						
					}
                	});
                
                listPreftime.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
					
					public boolean onPreferenceChange(Preference preference, Object newValue) {
						// TODO Auto-generated method stub
						
                         if(listPreftime.equals("1")){
                        	 time = 300000;
						};
						if(listPreftime.equals("2")){
							time = 900000;
						};
						if(listPreftime.equals("3")){
							time = 1800000;
						};
						if(listPreftime.equals("4")){
							time = 3600000;
						};
						if(listPreftime.equals("5")){
							time = 7200000;
						};
                        if(listPreftime.equals("6")){
                        	time = 14400000;
						};
                        if(listPreftime.equals("7")){
                        	time = 28800000;
						};
						
						
						return true;
					}
				});
             
        }
}